<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:insert="common/person-pc/header::personHeadBar('投稿详情','/static/highlight/dark.min.css,/static/Kz.layedit/Content/Layui-KnifeZ/css/layui.css,/static/css/person/paper.css')">

<body class="centre shop" style="">
<!-- 头部 -->
<!-- 头部信息 -->
<div th:insert="common/person-pc/top::personTopBar(${resCategoryModel})"/>
<div class="ey-body-bg">
    <div class="ey-body">
        <div class="ey-container w1200">
            <!-- 侧边 -->
            <div th:insert="common/person-pc/right::rightBar(${show})"/>
            <!-- 中部 -->
            <div class="ey-con fr">
                <div class="el-main main-bg">
                    <div class="column-title mb20">
                        <div class="column-name">发布投稿</div>
                    </div>
                    <!-- 内容栏 -->
                    <div class="ey-con-forms custom-form mt30">
                        <form id="post_form">
                            <input type="hidden" name="channel" value="0">
                            <div class="item-from-row">
                                <div class="from-row-l">
                                    <span class="red">*</span> 文章标题：
                                </div>
                                <div class="from-row-r">
                                    <input type="text" name="title" value="" id="title" class="el-input__inner w500"
                                           maxlength="100">
                                </div>
                            </div>
                            <div class="item-from-row">
                                <div class="from-row-l">
                                    <span class="red">*</span> 所属栏目：
                                </div>
                                <div class="from-row-r">
                                    <div class="w300 select">
                                        <select name="typeid" id="typeid">
                                            <option value="0">请选择栏目</option>
                                            <option value="1" data-channel="1" selected="true">免费资源</option>
                                            <option value="6" data-channel="1">&nbsp; &nbsp;推广</option>
                                            <option value="7" data-channel="1">&nbsp; &nbsp;运营</option>
                                            <option value="8" data-channel="1">&nbsp; &nbsp;营销</option>
                                            <option value="1" data-channel="1">免费资源</option>
                                            <option value="6" data-channel="1">&nbsp; &nbsp;推广</option>
                                            <option value="7" data-channel="1">&nbsp; &nbsp;运营</option>
                                            <option value="8" data-channel="1">&nbsp; &nbsp;营销</option>
                                            <option value="2" data-channel="1">付费资源</option>
                                            <option value="3" data-channel="1">会员专享</option>
                                            <option value="4" data-channel="1">网络资源</option>
                                        </select></div>
                                </div>
                            </div>
                            <div class="item-from-row">
                                <div class="from-row-l">
                                    TAG标签：
                                </div>
                                <div class="from-row-r">
                                    <input type="text" value="" name="tags" id="tags" class="el-input__inner w500"
                                           placeholder="多个标签之间用逗号隔开">
                                </div>
                            </div>
                            <!-- 单张图 start -->
                            <div class="item-from-row">
                                <div class="from-row-l">
                                    缩略图：
                                </div>
                                <div class="from-row-r">
                                    <div tabindex="0" class="input-file-show"
                                         onclick="$('#upload_single_pic_litpic_inpiut').trigger('click');"
                                         style="cursor: pointer;">
                                        <img class="img-fluid img1_litpic_inpiut" src="/static/images/not_upload_pic.png"/>
                                    </div>
                                </div>
                                <input type="file" name="litpic_inpiut_file" onchange="upload_single_pic(this,'litpic_inpiut')" style="display: none;">
                            </div>
                            <div class="item-from-row">
                                <div class="from-row-l">
                                    内容：
                                </div>
                                <div class="from-row-r">
                                    <textarea id="lay_edit" lay-verify="content" name="text"
                                              style="display: none"></textarea>
                                </div>
                            </div>
                            <div class="item-from-row">
                                <div class="from-row-l">&nbsp;</div>
                                <div class="from-row-r">
                                    <div class="layui-input-block">
                                        <button class="layui-btn" lay-submit lay-filter="addActive">立即提交</button>
                                    </div>
                                </div>
                            </div>
                            <!-- 表单验证 -->
                            <input type='hidden' name='__token__' value='1f67ffebc5cc1ad36a6f8c1e730123ba'/>
                        </form>
                    </div>
                    <!-- 内容栏结束 -->
                </div>
            </div>
        </div>
    </div>
</div>
<script th:src="@{'/static/Kz.layedit/Content/Layui-KnifeZ/layui.js'}"></script>
<script th:src="@{'/static/Kz.layedit/Content/ace/ace.js'}"></script>
<script th:src="@{'/static/highlight/highlight.js'}"></script>
<script>hljs.highlightAll()</script>
<script type="text/javascript">
    var index;
    var layedit;
    layui.use(['layedit', 'form'], function () {
        var form = layui.form;
        layedit = layui.layedit;
        layedit.set({	//设置图片接口
            uploadImage: {
                url: '/user/uploadImage', //接口url
                type: 'post'
            },
            devmode: true
            ,
            codeConfig: {
                hide: false,  //是否显示编码语言选择框
                default: 'java' //hide为true时的默认语言格式
            }
            , tool: [
                'html', //显示富文本源码
                'undo', //撤销
                'redo',//重做
                'code', //代码
                'strong',//加粗
                'italic', //斜体
                'underline', //下划线
                'del', //删除线
                'addhr', //水平线
                '|',
                'removeformat', //清楚文字样式
                'fontFomatt',//段落格式
                'fontfamily',//字体
                'fontSize', //字体大小
                'fontBackColor',//字体背景色
                'colorpicker',//字体颜色
                'face',//表情
                '|',
                'left', //左对齐
                'center', //居中
                'right', //右对齐
                '|',
                'link', //链接
                'unlink', //清除链接
                'image_alt', //图片alt
                '|', 'table',//表格
                'customlink'//自定义链接
                , 'fullScreen'//全屏
                , 'preview'//预览
            ],
            height: 500, //设置编辑器高度
        });
        //创建一个编辑器
        index = layedit.build('lay_edit', {
            height: 350
        });
        $(".layui-layedit .layui-unselect.layui-layedit-tool").append('<i id="lookCodeId" class="layui-icon layui-icon-search" title="在线预览" ></i>');
        $("#lookCodeId").click(function () {
            layer.open({
                title: '在线预览',
                shade: 0.2,
                content: layedit.getContent(index),
                area: ['90%', '90%'],//(top.window.innerHeight * 0.80).toString()]
            });
        });
        form.verify({
            content: function (value) {
                return layedit.sync(index);
            }
        });
        form.on('submit(addActive)', function (data) {
            let content = layedit.getContent(index);
            console.log(content);
            if (!$('#title').val()) {
                layer.msg('请填写文章标题！', {time: 1500, icon: 5});
                $('#title').focus();
                return false;
            }
            if (0 == $('#typeid').val()) {
                layer.msg('请选择所属栏目！', {time: 1500, icon: 5});
                $('#typeid').focus();
                return false;
            }
            var channel = $("#typeid option:selected").attr('data-channel');
            $("input[name='channel']").val(channel);

            layer_loading('正在处理');
            $.ajax({
                url: url,
                data: $('#post_form').serialize(),
                type: 'post',
                dataType: 'json',
                success: function (res) {
                    layer.closeAll();
                    if (1 == res.code) {
                        layer.msg(res.msg, {time: 1000}, function () {
                            window.location.href = res.url;
                        });
                    } else {
                        layer.msg(res.msg, {time: 1500, icon: 5});
                        if (res.data) $('#' + res.data).focus();
                    }
                },
                error: function (e) {
                    layer.closeAll();
                    showErrorAlert(e.responseText);
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });

</script>
<!-- 底部 -->
<div class="ey-footer">
    <footer class="container">
        <p>Copyright © 2012-2080 资源基地 版权所有</p>
    </footer>
</div>
</body>
</html>
<!-- 底部结束 -->
